from functional import pipeline
from pydash.collections import map_, filter_


def load_filter_preprocess(filter_fun, preprocess_fun):
    def anymous(file):
        return pipeline(file,
                        lambda f: open(f),
                        lambda rows: filter_(rows, filter_fun),
                        lambda rows: map_(rows, preprocess_fun)
                        )

    return anymous


normal_laf = load_filter_preprocess(lambda a: True, lambda row: row.strip('\n'))
